home *** CD-ROM | disk | FTP | other *** search
/ Click Press Kit / Click Press Kit.iso / pc / main.dxr / Internal_34_netOperations parent.ls < prev    next >
Encoding:
Text File  |  2006-05-31  |  1.6 KB  |  67 lines

  1. property pNetID, pNetDone, pCurrentAttempt, pMaxAttempts, pTextResult, pmode, pURL, pCallBackMethod, pPropertyList, pCallBackObject, pLocalFile
  2. global gNetQueue, gTracker
  3.  
  4. on new me, mode, url, callBackMethod, callBackObject, propertyList, localFile
  5.   pMaxAttempts = 3
  6.   pNetDone = 1
  7.   pmode = mode
  8.   pURL = url
  9.   pCallBackMethod = callBackMethod
  10.   pPropertyList = propertyList
  11.   pCallBackObject = callBackObject
  12.   pLocalFile = localFile
  13.   return me
  14. end
  15.  
  16. on mDestruct me
  17.   pCallBackObject = 0
  18. end
  19.  
  20. on mExecuteNetCommand me
  21.   case pmode of
  22.     #GET:
  23.       pNetID = getNetText(pURL)
  24.     #POST:
  25.       pNetID = postNetText(pURL, pPropertyList)
  26.     #preload:
  27.       pNetID = preloadNetThing(pURL)
  28.     #download:
  29.       pNetID = downloadNetThing(pURL, pLocalFile)
  30.   end case
  31.   pCurrentAttempt = 1
  32.   pNetDone = 0
  33. end
  34.  
  35. on mCallBackResults me
  36.   if pCallBackMethod.ilk <> #void then
  37.     if pCallBackObject.ilk = #void then
  38.       do(pCallBackMethod && "(" & QUOTE & pTextResult & QUOTE & ")")
  39.     else
  40.       call(pCallBackMethod, pCallBackObject, pTextResult)
  41.     end if
  42.   end if
  43. end
  44.  
  45. on mIsNetOpDone me
  46.   if netDone(pNetID) then
  47.     if netError(pNetID) = "OK" then
  48.       case pmode of
  49.         #GET, #POST:
  50.           pTextResult = netTextResult(pNetID)
  51.         otherwise:
  52.           pTextResult = EMPTY
  53.       end case
  54.       pNetDone = 1
  55.     else
  56.       if pCurrentAttempt < pMaxAttempts then
  57.         pCurrentAttempt = pCurrentAttempt + 1
  58.         me.mExecuteNetCommand()
  59.       else
  60.         pTextResult = "net error:" && netError(pNetID)
  61.         pNetDone = 1
  62.       end if
  63.     end if
  64.   end if
  65.   return pNetDone
  66. end
  67.